﻿/*-----------------------------------------------
// File: SpecialAngerBar.cs
// Description: 
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SpecialAngerBar : MonoBehaviour {

    public List<UISprite> innerSprites;

    public double currentValue;
    public double phaseTotalValue {
        get {
            return 1 / (double)innerSprites.Count;
        }
    }

    public double value {
        get { return currentValue; }
        set { SetValue(value); }
    }

    public void SetValue(double value) {
        currentValue = value;
        int i = 0; 
        for (i = 0; i < innerSprites.Count; ++i) {
            if (currentValue >= (i + 1) * phaseTotalValue)
            {
                innerSprites[i].fillAmount = 1;
            }
            else {
                float v = (float)((currentValue - i * phaseTotalValue) / phaseTotalValue);
                innerSprites[i].fillAmount = v;
                break;
            }
        }
        i++;
        for (; i < innerSprites.Count; ++i) {
            innerSprites[i].fillAmount = 0;
        }
    }
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
